﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PresentacionEscritorio
{
    public partial class frmAsignarTurno : Form
    {
        public frmAsignarTurno()
        {
            InitializeComponent();
            cargarGrilla();
        }

        private void cargarGrilla()
        {
            DateTime horaInicio = new DateTime(2014, 01, 01, 08, 00, 00);
            TimeSpan duracionTurno = new TimeSpan(0, 30, 0);
            int index = 0;
            while (true)
            {
                grdAgenda.Rows.Add();
                if (index == 0)
                    grdAgenda.Rows[index].Cells[0].Value = horaInicio.ToShortTimeString();
                else
                {
                    horaInicio = horaInicio + duracionTurno;
                    grdAgenda.Rows[index].Cells[0].Value = horaInicio.ToShortTimeString();
                }
                if (horaInicio.Hour < 17)
                    index++;
                else
                    break;
            }
            grdAgenda.Rows[5].Cells[3].Style.BackColor = Color.Red;
            grdAgenda.Rows[11].Cells[4].Style.BackColor = Color.Green;
        }

        private void grdAgenda_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (grdAgenda.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.Red)
                MessageBox.Show("Turno ocupado - dr. XX - Paciente YY");
            else if (grdAgenda.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor == Color.Green)
                MessageBox.Show("Turno disponible - registrar");
            else
                MessageBox.Show("No hay turno para el dia y hora seleccionado para este doctor");
                
        }

        private void frmAsignarTurno_Load(object sender, EventArgs e)
        {

        }

        private void grdAgenda_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

    }
}
